package com.cg.controller;

import com.cg.Dto.InsertUserDto;
import com.cg.Dto.SearchUserDto;
import com.cg.Dto.UpdateStatusDto;
import com.cg.Dto.UpdateUserDto;
import com.cg.entity.Personnel;
import com.cg.result.PageDTO;
import com.cg.result.R;
import com.cg.service.PersonnelService;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author lhy
 * @since 2024-12-26
 */
@RestController
@RequestMapping("/user")
public class PersonnelController {
    @Resource
    private PersonnelService personnelService;
    @GetMapping("/searchUser")
    @Schema(description = "分页查询人员列表接口")
    public R<Personnel> search (@ModelAttribute @Valid  SearchUserDto searchUserDto)
    {
        return  personnelService.searchuser(searchUserDto);
    }
    @PostMapping("/insertUser")
    public R<?> insert(@RequestBody @Valid InsertUserDto insertUserDto)
    {
        return  personnelService.insertuser(insertUserDto);
    }
    @PutMapping("/updateUser")
    @Schema(description = "修改人员接口")
    public R<?> uodate(@RequestBody @Valid UpdateUserDto updateUserDto)
    {
        return  personnelService.updateperson(updateUserDto);
    }
   @PutMapping("/updateStatus")
    @Schema(description = "修改用户状态接口")
    public R<?> updatestatus(@RequestBody @Valid UpdateStatusDto updateStatusDto){
        return  personnelService.updatestatus(updateStatusDto);
   }
}
